/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package src.com.dados.midiateca;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import src.com.dados.Conexao;
import src.com.negocio.midiateca.MaterialDidatico;
import src.com.negocio.midiateca.VendaMaterial;

/**
 *
 * @author Adriano
 */
public class VendaMaterialDAO {

    MaterialDidatico material = new MaterialDidatico();

    public boolean venderMaterial(VendaMaterial novaVenda) {
        Connection con;

        con = Conexao.getInstance().getCon();
        
        
        String sql = "INSERT INTO venda (codigo_mat, quantidade, forma_pagamento, valor_total) values (?,?,?,?)";
        
        PreparedStatement pstmt;

        try {
            // cria um preparedStatement
            pstmt = con.prepareStatement(sql);

            // preenche os valores
            pstmt.setInt(1, novaVenda.getCodMaterial());
            pstmt.setInt(2, novaVenda.getQuantidadeVendida());
            pstmt.setString(3, novaVenda.getFormaPagamento());
            pstmt.setFloat(4, novaVenda.getValorTotal());

            pstmt.executeUpdate();
            
            
            System.out.println("Venda realizada!");
            
            return true;
        } catch (SQLException e) {
            System.out.println(e);
        }
        return false;
    }

   
    
}
